<template>
  <div class="home-hot">
    <HomePanel title="人气推荐" subTitle="人气爆款 不容错过">
      <template v-slot:right><XtxMore path="/" /></template>
      <div ref='target' style="position: relative;height: 406px;">
      <Transition name="fade">
      <ul class="goods-list" v-if="hots.length">
        <li v-for="item in hots" :key="item.id">
          <RouterLink to="/">
            <img v-lazy="item.picture" alt="" />
            <p class="name">{{ item.title }}</p>
            <p class="desc">{{ item.alt }}</p>
          </RouterLink>
        </li>
      </ul>
      <HomeSkeleton bg="#f0f9f4" v-else />
      </Transition>
      
      </div>
    </HomePanel>
  </div>
</template>

<script>
import { findHot } from "@/api/home"
import HomePanel from "./HomePanel.vue"
import HomeSkeleton from './HomeSkeleton.vue'
import { useLazyFn } from '@/hooks'
export default {
  name: "HomeHot",
  components: { HomePanel, HomeSkeleton },
  setup() {
    // 获取人气推荐数据
    // let hots = ref([])
    // findHot().then((data) => {
    //   hots.value = data.result;
    // })
    const {target,result} = useLazyFn(findHot)
    return { hots:result,target }
  }
}
</script>

<style lang="less" >
.goods-list {
  display: flex;
  justify-content: space-between;
  height: 426px;
  li {
    width: 306px;
    height: 406px;
    .hoverShadow();
    img {
      width: 306px;
      height: 306px;
    }
    p {
      font-size: 22px;
      padding-top: 12px;
      text-align: center;
    }
    .desc {
      color: #999;
      font-size: 18px;
    }
  }
}
</style>